<template>
  <div>
    <!-- 判断当前用户是否已经登录，如果登录，则显示昵称，如果没有登录则显示登录按钮 -->
    <div v-if="!nickname" @click="goLogin">立即登录</div>
    <div v-else>{{ nickname }}</div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  computed: {
    ...mapGetters(['nickname'])
  },
  methods: {
    goLogin() {
      this.$router.push('/login')
    }
  }
}
</script>

<style lang="scss" scoped></style>
